package yth.api.user.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.w3c.dom.DocumentType;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2Configuration {

	@Bean
	public Docket accessToken() {
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("api") //定义组
				.select() //选择哪些路径和api 会生成document
				.apis(RequestHandlerSelectors.basePackage("yth.api.user.web"))//拦截的包路径
				.paths(PathSelectors.regex("/*/.*")) //拦截的接口路径
				.build() //创建
				.apiInfo(apiInfo()); //配置说明
				
	}
	
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("云天化接口文档")  //标题
				.description("物流终端用户")  //描述
				.termsOfServiceUrl("http://www.xx.com")
				.contact(new Contact("请联系", "www.xx.com", "874757177@qq.com"))
				.version("1.0")
				.build();
	}
}
